import { defineStore } from "pinia";
import { ref,reactive,resolveComponent } from "vue";
import {  useRouter  } from 'vue-router';

export const usePageTbStore = defineStore('page', () => {
    let pageRecords=reactive({
        current:1,
        pages:0,
        record:[],
        size:0,
        total:0

    })

    const setPageRecords=(newPageData)=>{
       // 使用对象展开语法更新 pageRecords 的属性
        pageRecords = { ...newPageData };
    }

    // const getPageTotal=computed(()=>pageTotal.value)
   return{
    pageRecords,setPageRecords
   } 
})

export const useIMStore = defineStore('IMmessage', () => {
    let columns=reactive([
        {
            title: '姓名',
            key: 'realName',
            align: 'center'
        },
        {
            title: '农作物',
            key: 'item',
            align: 'center'
        },
        {
            title: '联系方式',
            key: 'phone',
            align: 'center'
        },
        {
            title: '种植面积（亩）',
            key: 'area',
            align: 'center'
        },
        {
            title: '金额（元）',
            key: 'amount',
            align: 'center'
        },
        {
            title: '地址',
            key: 'address',
            align: 'center'
        }
    ])

    const router=useRouter()

    let columns2=reactive([
        {
            title: '序号',
            key: 'index',
            align: 'center'
        },
        {
            title: '姓名',
            key: 'realName',
            align: 'center'
        },
        {
            title: '申请金额',
            key: 'money',
            align: 'center'
        },
        {
            title: '利率',
            key: 'rate'
            ,
            align: 'center'
        },
        {
            title: '还款时间',
            key: 'repayment',
            
            align: 'center'
           
        },
         // status：0：申请中 1：驳回 2：申请通过
        {
            title: '状态',
            // key: 'status',
            slot: 'status',
            align: 'center'
        },
        {
            title: '组合贷款人',
            key: 'combinationName1',
            align: 'center'
        },
        {
            title: '创建时间',
            key: 'createTime',
            align: 'center'
        },
        {
            title: '更新时间',
            key: 'updateTime',
            align: 'center'
        }, 
        {
            title: '操作',
            key: 'action',
            align: 'center',
            render: (h, params) => {
                return h('span', {
                    style: {
                        color: '#19be6b',
                        cursor: 'pointer'
                    },
                }, params.row.action);
            }
        } 
    ])

    let flag=ref(1)
    const setflag=(newFlag)=>{
       flag.value=newFlag
    }



   return{
    columns,flag,setflag,columns2
   } 
})
